<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>日报管理</title>
    <link rel="stylesheet" type="text/css" href="./easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="./easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="./easyui/themes/color.css">
    <script type="text/javascript" src="./easyui/jquery.min.js"></script>
    <script type="text/javascript" src="./easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
<div class="easyui-panel" style="padding:15px 5px;width:100%;">
      当前用户：<span id="login_user"></span> | 切换用户：<input id="cc" name="cuser" value=""> |
      <a href="javascript:void(0)" onclick="sendMaid()" class="easyui-linkbutton" data-options="iconCls:'icon-email'">发送日报</a> |
      <a href="javascript:void(0)"  class="easyui-linkbutton" data-options="iconCls:'icon-email'" onclick="$.loginOut()" >退出登录</a>
      <a href="user.html"  class="easyui-linkbutton" data-options="iconCls:'icon-email'"  >修改信息</a>
  </div>
  <div class="easyui-panel" style="padding:15px 5px;width:100%;">
      <a href="report.html" class="easyui-linkbutton" data-options="toggle:true,group:'g2',plain:true">日报管理</a>
      <a href="plan.html" class="easyui-linkbutton" data-options="toggle:true,group:'g2',plain:true ,selected:true">计划管理</a>
      <a href="mail.html" class="easyui-linkbutton" data-options="toggle:true,group:'g2',plain:true ">邮件管理</a>
      <a href="log.html" class="easyui-linkbutton" data-options="toggle:true,group:'g2',plain:true ">发送记录</a>
  </div>

    <table id="dg" data-options="" style="width:100%;">

    </table>

  <div id="w" class="easyui-window" title="新增" data-options="iconCls:'icon-save',closed:true" style="width:700px;height:500px;padding:10px;">
      <form id="ff" method="post">
          <table style="width:100%;">
              <tr>

                  <td>项目:
                    <input id="data_id" name="id" hidden>
                  </td>
                  <td><input name="project" class="easyui-textbox"></input></td>
                  <td>完成状态:</td>
                  <td >
                      <select class="easyui-combobox" name="status" style="width:179px;">
                          <option value="未开始">未开始</option>
                          <option value="进行中" selected>进行中</option>
                          <option value="已完成">已完成</option>
                          <option value="已延期">已延期</option>
                      </select></td>
              </tr>

              <tr>
                  <td>子项目:</td>
                  <td colspan="3"><input name="subProject" style="width:505px;height:50px;" multiline="true" class="easyui-textbox"></input></td>
              </tr>
              <tr>
                  <td>开始时间:</td>
                  <td><input name="startTime" data-options="formatter:$.myformatter,parser:$.myparser" class="easyui-datebox"></input></td>
                  <td>结束时间:</td>
                  <td><input name="endTime" data-options="formatter:$.myformatter,parser:$.myparser" class="easyui-datebox"></input></td>
              </tr>

              <tr>
                  <td>备注:</td>
                  <td colspan="3"><input name="remark" style="width:505px;height:50px;" multiline="true" class="easyui-textbox"></input></td>
              </tr>

              <tr>
                  <td colspan="4" style="text-align:center;padding-top:20px;">

                      <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">提交</a>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <a href="javascript:void(0)" class="easyui-linkbutton" onclick="cannel()" style="width:80px">取消</a>
                  </td>
              </tr>
          </table>
      </form>
  </div>



    <script type="text/javascript">
        var toolbar = [{
            text:'新增',
            iconCls:'icon-add',
            handler:function(){
                $('#ff').form('clear');
                $('#w').window('open')
                 $('#w').form('load',{
                    status:'进行中',
                    startTime:new Date().Format('yyyy-MM-dd')
                 })
            }
        },{
            text:'删除',
            iconCls:'icon-remove',
            handler:function(){
                var select = $('#dg').datagrid('getSelections');
                if(!select || select.length==0 ){
                    $.messager.alert('提示','请选中要删除的数据');
                    return;
                }
                $.messager.confirm('确认','是否删除?',function(r){

                    if (r){
                        var param = '';
                        for(var i=0;i<select.length;i++){
                            param += select[i].id + ',';
                        }
                        del({id:param});
                    }
                });
            }
        },{
            text:'导出',
            iconCls:'icon-large-smartart',
            handler:function(){
               window.location.href = path+"export/exportReport.do";
            }
        }];

        $('#dg').datagrid({
            columns:[[
                {field:'ck',checkbox:true},
                {field:'createTime',title:'发生时间'},
                {field:'project',title:'项目'},
                {field:'status',title:'完成状态'},
                {field:'subProject',title:'子项目'},
                {field:'startTime',title:'开始时间'},
                {field:'endTime',title:'结束时间'},
                {field:'remark',title:'备注'}
            ]],
            toolbar:toolbar,
            onDblClickRow:function(index,row){
                $('#w').window('open');
                $('#w').form('load',row)
            },
            rownumbers:true,
            singleSelect:false,
            pagination:true,
            url:'plan/getAllPage.do',
            pageSize:20,
            pageList:[20,30,40,60,100,200,1000]
        });


        function loadData(){
             $('#dg').datagrid('reload')
            return ;
        }

        //loadData();
        function submitForm(){
            var d={};
            var t = $('#ff').serializeArray();
            $.each(t, function() {
              d[this.name] = this.value;
            });
            if(d.id!=null&&d.id.length>0){
                modify(d);
            }else{
                add(d);
            }

        }

        function del(data){
             $.cpost('plan/delete.do',data,function(data){
                $.messager.alert('提示','删除成功');
                loadData();
            });
        }

        function add(data){
            $.cpost('plan/add.do',data,function(data){
                $.messager.alert('提示','添加成功');
                $('#w').window('close');
                $('#ff').form('clear');
                loadData();
            });
        }
        function modify(data){
            $.cpost('plan/modify.do',data,function(data){
                $.messager.alert('提示','修改成功');
                $('#w').window('close');
                $('#ff').form('clear');
                loadData();
            });
        }

        function cannel(){
            $('#w').window('close');
        }


		function removeit(){

		}

    </script>
<script type="text/javascript" src="./js/common_head_hand.js"></script>
</body>
</html>
